-module(mandelbrot).
-export([run/0]).
-import(lists, [foreach/2]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% WORK IN PROGRESS
%
% Goal: create an Erlang version of this benchmark:
% http://www.timestretch.com/FractalBenchmark.html
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

run() ->
	statistics(wall_clock),
	io:fwrite("Hello world!~n", []),
	X = lists:seq(1,10),
	
	PrintInt = fun(I) -> io:fwrite("~p~n", [I]) end,
	lists:foreach(PrintInt, X),
	
	{_, Time1} = statistics(wall_clock),
	U1 = Time1 * 1000,
	io:fwrite("Elapsed: ~p microseconds~n", [U1]).


walk_matrix(F, Min, Max) -> walk_matrix(F, Min, Max, Min, Min ).
       
walk_matrix(_, _, Max, _, Y) when (Y =:= Max+1) -> none;
walk_matrix(F, Min, Max, X, Y) when (X =:= Max+1) -> 
	F(X,Y), walk_matrix(F, Min, Max, Min, Y+1);
walk_matrix(F, Min, Max, X, Y) -> 
	F(X,Y), walk_matrix(F, Min, Max, X+1, Y).

mandelbrot(X, Y) -> none.

% for(Max, Max, F) -> [F(Max)];
% for(I, Max, F)   -> [F(I)|for(I+1, Max, F)].

% print_list(L, Fmt) ->
% 	lists:foreach(fun(I) -> io:fwrite(Fmt, [I]) end, L).

% print_list([], Fmt) -> [];
% print_list([H|T], Fmt) ->
% 	io:fwrite(Fmt, [H]),
% 	print_list(T, Fmt).
